﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using XmlStudio.DataLayer;
using XmlStudio.Interfaces;
using System.Windows;
using System.Windows.Controls;

namespace XmlStudio.ViewModel.Node {
    [DebuggerDisplay("Name: {Name}")]
    public class XsdElementViewModel : XmlElementViewModel {
        private XsdElement elementType;
        private EditXsdElementParam editParam;

        public XsdElement ElementType { get { return this.elementType; } }

        public EditXsdElementParam EditParam { get { return this.editParam; } }

        public ContextMenu ContextMenu {
            get {
                XsdElement? parent;
                if(this.Node.Parent != null) {
                    parent = XsdElementParser.GetElementType(this.Node.Parent.LocalName);
                } else {
                    parent = null;
                }

                return XsdContextMenu.CreateContextMenu(this.ElementType, parent, this.Node, this.CommandTarget);
            }
        }

        public XsdElementViewModel(BigXmlNode node, XsdElement elementType, IInputElement commandTarget)
            : base(node, commandTarget) {
            this.elementType = elementType;
            this.editParam = new EditXsdElementParam { ElementType = this.elementType, Node = node, Element = this };
        }
    }
}